# To change this template, choose Tools | Templates
# and open the template in the editor.

module SueldosHelper

  def empresa_grouped_options
    grouped_options = {}
    Empresa.all.each do |empresa|
      grouped_options[empresa.nombre] = empresa.sucursales.map(&sucursal_option_for_select)
      grouped_options[empresa.nombre].unshift(["TODAS - #{empresa.nombre}","#{empresa.id}"])
    end
    grouped_options_for_select(grouped_options,nil,"Todas") # this is a Rails form helper method
  end
  
    def sucursal_option_for_select
    lambda {|record| ["#{record.nombre} - #{record.empresa.nombre}", record.id] }
  end


end
